#pragma once

#include "GalconCommonTypes.h"
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
const double countOfShipsMultiplyFactor = 0.5;

class PlanetInternalImpl : private boost::noncopyable
{
public:
   PlanetInternalImpl(PlanetID planetID, double countOfShips = 0, PlayerID playerID = undefinedPlayerID,
                      double x = 0.0, double y = 0.0, PlanetSize planetSize = mediumPlanet, 
                      GamePlanets textureID = Moon);
   virtual ~PlanetInternalImpl();
   void IncreaseCountOfShips();
   void SetCountOfShips(double countOfShips);
   PlanetID GetPlanetID() const;
   PlanetSize GetPlanetSize() const;
   GameColors GetPlanetColor() const;
   GamePlanets GetPlanetTextureID() const;
   unsigned int GetCountOfShips() const;
   PlayerID GetPlayerID() const;
   void SetPlayerID(PlayerID playerID);
   double GetX() const;
   double GetY() const;
private:
   //   (0.0,0.0)__________________________________(1.0,0.0)
   //           |                                  | 
   //           |                                  |
   //           |                                  |
   //           |                                  |
   //           |                                  |
   //           |                                  |
   //           |                                  |
   //           |__________________________________|
   //   (0.0,1.0)                                  (1.0,1.0)
   // holds y coordinate of the planet, number between 0.0 and 1.0.
   const double m_x;
   // holds y coordinate of the planet, number between 0.0 and 1.0.
   const double m_y;
   // count of ships that currently located on planet
   double m_countOfShips;
   // planet size
   const PlanetSize m_planetSize;
   // player id which owns current planet
   PlayerID m_playerID;
   // planet ID
   const PlanetID m_planetID;
   // planet Texture id
   const GamePlanets m_planetTextureID;
};

inline GamePlanets PlanetInternalImpl::GetPlanetTextureID() const
{
   return m_planetTextureID;
}

inline GameColors PlanetInternalImpl::GetPlanetColor() const
{
   if (m_playerID != undefinedPlayerID)
      return GameColors(m_playerID);
   else
      return white;
}

inline double PlanetInternalImpl::GetX() const
{
   return m_x;
}

inline double PlanetInternalImpl::GetY() const
{
   return m_y;
}

inline void PlanetInternalImpl::IncreaseCountOfShips()
{
   m_countOfShips += countOfShipsMultiplyFactor * m_planetSize;
}

inline void PlanetInternalImpl::SetCountOfShips(double countOfShips)
{
   m_countOfShips = countOfShips;
}

inline unsigned int PlanetInternalImpl::GetCountOfShips() const
{
   return static_cast<unsigned int>(m_countOfShips);
}

inline PlanetSize PlanetInternalImpl::GetPlanetSize() const
{
   return m_planetSize;
}

inline PlayerID PlanetInternalImpl::GetPlayerID() const
{
   return m_playerID;
}

inline void PlanetInternalImpl::SetPlayerID(PlayerID playerID)
{
   m_playerID = playerID;
}

inline PlanetID PlanetInternalImpl::GetPlanetID() const
{
   return m_planetID;
}

typedef boost::shared_ptr<PlanetInternalImpl> PlanetInternalImplPtr;